#!/usr/bin/env bash
# Summary: Explain how the current PHP version is set
set -e
[ -n "$PHPENV_DEBUG" ] && set -x

unset PHPENV_VERSION_ORIGIN

IFS=$'\n' read -d '' -r -a scripts <<<"$(phpenv-hooks version-origin)" || true
for script in "${scripts[@]}"; do
  # shellcheck disable=SC1090
  source "$script"
done

if [ -n "$PHPENV_VERSION_ORIGIN" ]; then
  echo "$PHPENV_VERSION_ORIGIN"
elif [ -n "$PHPENV_VERSION" ]; then
  echo "PHPENV_VERSION environment variable"
else
  phpenv-version-file
fi
